<?php
header('Content-Type: text/xml');
?> 
<?php 

include("../db/opendb.php");

include("functions.php");

/*$query1 = "select AVG(Price_Per_SQFT) as avg from Game_Data where City = 'San Francisco' and Property_Type = 'RESI' and Selling_Date >= DATE_SUB(now(), INTERVAL 3 month);";
$result1 = mysql_query($query1) or die ("SQL Error".mysql_error());
$row1 = mysql_fetch_assoc($result1);*/
//echo $row1['avg'];

$query = "select g.Listing_Number, g.Price_Per_SQFT, g.Longitude, g.Latitude, g.Address, g.Current_Price, g.Beds, g.Baths, g.SQFT, g.Status from Game_Data g inner join Game_Districts d on g.District = d.District_Number where Status in ('A', 'ACTIVE', 'C') and g.Listing_Date > DATE_SUB(CURDATE(),INTERVAL 14 DAY) and d.Parent = '" . $_GET['district_number']."'";

$result = mysql_query($query) or die ("SQL Error".mysql_error());

$xml = "<markers>";

while ($row = mysql_fetch_assoc($result))
{
	$xml .= "<marker lng='".$row[Longitude]."' lat='".$row[Latitude]."'>";
	$xml .= "<id><![CDATA[".$row['Listing_Number']."]]></id>";
	$xml .= "<info><![CDATA[".$row['Address']."]]></info>";
	$xml .= "<beds><![CDATA[".$row['Beds']."]]></beds>";
	$xml .= "<baths><![CDATA[".$row['Baths']."]]></baths>";
	$xml .= "<price><![CDATA[$".number_format($row['Current_Price'], 0)."]]></price>";
	//$xml .= "<apps><![CDATA[".number_format(($row['Price_Per_SQFT']/$row1['avg'])*100, 2)."%]]></apps>";
	$xml .= "<pps><![CDATA[".$row['Price_Per_SQFT']."]]></pps>";
	$xml .= "</marker>";
}
$xml .= "</markers>";

echo $xml;

?>
